package study.javaee.practice.entity;

import lombok.Data;

import javax.persistence.Basic;
import javax.persistence.Column;
import java.io.Serializable;

@Data
public class JpaProIduserIdPK implements Serializable {

    @Basic
    @Column(name="project_id")
    Integer projectId;

    @Basic
    @Column(name="user_id")
    Integer userId;

    @Override
    public int hashCode() {
        final int PRIME = 31;
        int result = 1;
        result = PRIME * result + ((userId == null) ? 0 : userId.hashCode());
        result = PRIME * result + ((projectId == null) ? 0 : projectId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj){
        if(this == obj){
            return true;
        }
        if(obj == null){
            return false;
        }
        if(getClass() != obj.getClass()){
            return false;
        }

        final JpaProIduserIdPK other = (JpaProIduserIdPK)obj;
        if(userId == null){
            if(other.userId != null){
                return false;
            }
        }else if(!userId.equals(other.userId)){
            return false;
        }
        if(projectId == null){
            if(other.projectId != null){
                return false;
            }
        }else if(!projectId.equals(other.projectId)){
            return false;
        }

        return true;
    }

}
